package timetable.db;
import java.sql.*;
import java.util.ArrayList;

public class PostgreSQLDatabase {
ujhvbivg
}

	
	public void makeConnection(){
	String driver = "org.postgresql.Driver";
	Connection conn = null;

	
	TimeTableParser parser = new TimeTableParser();
	ArrayList<String> lijst = parser.MaakQuery();
	
	
	try {
		Class.forName(driver);
		String url="jdbc:postgresql://127.0.0.1:5432/Roosters";
		conn = DriverManager.getConnection(url,"postgres","admin");
		Statement stat = conn.createStatement();
		stat.executeUpdate("TRUNCATE TABLE ROOSTER");
		stat.close();
		/*Statement stbt = conn.createStatement();
		stbt.executeUpdate("CREATE TABLE ROOSTER"
+"("
+"duur character(20),"
+"docent character(300),"
+"vak character(200),"
+"klassen character(200),"
+"lokaal character(200),"
+"dag character(20),"
+"startuur character(20),"
+"id serial NOT NULL,"
+" CONSTRAINT \"PK_id\" PRIMARY KEY (id)"
+")"
+"WITH ("
+"OIDS=FALSE"
+");"
+"ALTER TABLE rooster OWNER TO postgres;");
		stbt.close();*/
		
		for(String s: lijst){
			Statement stmt = conn.createStatement();
			String queryString = "INSERT INTO ROOSTER VALUES("+s;
			stmt.executeUpdate(queryString);
			stmt.close();
		}
		 conn.close();
		
	}		
	catch (Exception e) {
        System.out.println("Error: " + e);
	} 
	}
}

